<!--
 * @Author: your name
 * @Date: 2021-01-08 21:14:41
 * @LastEditTime: 2021-01-20 00:38:07
 * @LastEditors: Please set LastEditors
 * @Description: 广告页面
 * @FilePath: \vue-web-seed\src\page\home\index.vue
-->
<template>
  <div class="home">
    <div class="img-one">
      <img src="/static/images/write-back/01.jpg" />
      <div class="code"><p>nh6990</p></div>
      <div class="button copy-text">
        <p>点击复制去微信</p>
      </div>
    </div>
    <img src="/static/images/write-back/02.jpg" />
    <div class="img-three">
      <img src="/static/images/write-back/03.jpg" />
      <div class="code"><p>nh6990</p></div>
      <div class="button copy-text">
        <p>点击复制去微信</p>
      </div>
    </div>

    <img src="/static/images/write-back/04.jpg" />
    <div class="img-five">
      <img src="/static/images/write-back/05.jpg" />
      <div class="code"><p>nh6990</p></div>
      <div class="button copy-text">
        <p>点击复制去微信</p>
      </div>
    </div>

    <img src="/static/images/write-back/06.jpg" />
    <img src="/static/images/write-back/07.jpg" />
    <div class="img-eight">
      <img src="/static/images/write-back/08.jpg" />
      <div class="code"><p>nh6990</p></div>
      <div class="button copy-text">
        <p>点击复制去微信</p>
      </div>
    </div>
    <img src="/static/images/write-back/09.jpg" />

    <!-- 弹出层 -->
    <van-dialog
      closeOnClickOverlay
      class="member-van-dialog"
      v-model="pupShow"
      :showConfirmButton="false"
    >
      <p class="dialog-title">公众号已复制</p>
      <div class="dialog-main">
        <p class="dialog-code"><span>nh6990</span></p>
        <p class="dialog-hint">打开微信 ，粘贴搜索该公众号</p>
        <!-- gif -->
        <div class="dialog-gif">
          <div class="dialog-gif-content">
            <img src="/static/images/write-back/tuiguang.gif" />
          </div>
        </div>

        <div class="to-wx">
          <van-button color="#317ab5" @click="toWeiXin"
            >打开微信关注公众号</van-button
          >
        </div>
      </div>
    </van-dialog>

    <!-- 底部悬浮按钮 -->
    <div class="button-box">
      <div class="button-left">
        <p class="button-title">
          <span>公众号：</span> <span class="code">nh6990</span>
          <span class="copy-text">（ 点击复制 ）</span>
        </p>
        <p class="warn">一手货源 、假一赔十</p>
      </div>
      <div class="button-right" @click="toWeiXin">去微信</div>
    </div>
  </div>
</template>

<script>
import Clipboard from "clipboard";
export default {
  data() {
    return {
      clipboard: null,
      pupShow: false, //复制成功弹框
    };
  },
  methods: {
    /* 初始化剪切板 */
    initClipboard() {
      if (!this.clipboard) {
        this.clipboard = new Clipboard(".copy-text", {
          text: () => {
            return "nh6990";
          },
        });
        this.clipboard.on("success", (e) => {
          this.pupShow = true;
          this.$notify({ type: "primary", message: "复制成功" });
        });
      }
    },
    //打开微信
    toWeiXin() {
      window.location.href = "weixin://";
    },
  },
  mounted() {
    this.initClipboard();
    document.querySelectorAll(".code").forEach((codeDom) => {
      
      codeDom.addEventListener("copy", () => {
        this.pupShow = true;
        this.$notify({ type: "primary", message: "复制成功" });
      });
    });
  },
};
</script>


<style lang="scss" scoped>
.home {
  width: 100%;
  img {
    width: 100%;
  }
  .img-one,
  .img-three,
  .img-five,
  .img-eight {
    position: relative;
    .code {
      width: 160px;
      height: 45px;
      line-height: 45px;
      position: absolute;
      left: 50%;
      transform: translate(-50%);
      bottom: 100px;
      margin-top: 10px;
      background-color: #feff2b;
      text-align: center;
      p {
        width: 100%;
        text-align: center;
        font-size: 30px;
        color: red;
        font-weight: bold;
        /*  animation: p_blow_up cubic-bezier(0.64, 0.41, 0.87, 0.35) 0.7s infinite
          alternate; */
      }
    }
  }
  .img-three {
    .button {
      bottom: 35px;
    }
  }
  .img-five {
    .button {
      bottom: 35px;
    }
  }

  .img-eight {
    .button {
      bottom: 35px;
    }
  }
  .button {
    position: absolute;
    bottom: 45px;
    width: 200px;
    text-align: center;
    line-height: 44px;
    height: 44px;
    background-color: #cf3b2f;
    left: 50%;
    color: #fff;
    letter-spacing: 1px;
    border-radius: 40px;
    font-size: 16px;
    animation: blow_up cubic-bezier(0.64, 0.41, 0.87, 0.35) 0.7s infinite
      alternate;
    box-shadow: 0px 4px 5px rgba(8, 8, 8, 0.5);
  }
  .button-box {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 70px;
    background-color: rgba(20, 19, 20, 0.8);
    display: flex;
    color: #fff;
    .button-left {
      flex: 7;
      .button-title {
        margin-top: 10px;
        height: 30px;
        display: flex;
        span {
          display: flex;
          align-items: center;
          justify-content: center;
          text-align: center;
          flex: 1;
          &:first-child {
            font-size: 14px;
          }
          &:nth-child(2) {
            font-size: 25px;
            color: #feff2b;
          }
          &:last-child {
            color: red;
            font-size: 10px;
          }
        }
      }
      .warn {
        font-size: 15px;
        text-align: center;
      }
    }
    .button-right {
      flex: 3;
      background-color: #cd342c;
      font-size: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }

  .member-van-dialog {
    height: 350px;
    width: 300px;
    border-radius: 4px;
    // background-color: #fff;
    background-color: #317ab5;
    .dialog-title {
      height: 40px;
      text-align: center;
      line-height: 40px;
      font-size: 20px;
      color: #fff;
      letter-spacing: 2px;
    }
    .dialog-main {
      overflow: hidden;
      background-color: #fff;
      height: 306px;
      margin: 0px 4px 3px;
      .dialog-code {
        margin-top: 10px;
        text-align: center;
        span {
          height: 30px;
          line-height: 30px;
          display: inline-block;
          width: 100px;
          text-align: center;
          font-size: 20px;
          color: red;
          font-weight: bold;
          background-color: #feff2b;
        }
      }
      .dialog-hint {
        margin-top: 5px;
        font-size: 14px;
        color: #959297;
        text-align: center;
      }
      .dialog-gif {
        margin-top: 5px;
        display: flex;
        justify-content: center;
        .dialog-gif-content {
          width: 200px;
          height: 170px;
          // background-color: #feff2b;
          overflow: hidden;
        }
      }

      .to-wx {
        margin-top: 10px;
        text-align: center;
        span {
          font-size: 20px;
        }
      }
    }
  }
}
@keyframes blow_up {
  0% {
    transform: translate(-50%) scale(0.8);
  }
  100% {
    transform: translate(-50%) scale(1.1);
  }
}
/* @keyframes p_blow_up {
  0% {
    transform:  scale(1);
  }
  100% {
    transform:  scale(1.5);
  }
}  */
</style>
